package com.ysfxt.exception;

import com.ysfxt.result.ResultCodeEnum;
import lombok.Data;

/**
 * @author 盐酸氟西汀
 * @create 2024/3/29 19:27
 * @email 480738950@qq.com
 */
@Data
public class YsfxtException extends RuntimeException{
    //异常状态码
    private Integer code;
    
    /**
     * 通过状态码和错误消息创建异常对象
     * @param message
     * @param code
     */
    public YsfxtException(String message, Integer code) {
        super(message);
        this.code = code;
    }
    
    /**
     * 接收枚举类型对象
     * @param resultCodeEnum
     */
    public YsfxtException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }
    
    @Override
    public String toString() {
        return "YsfxtException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}